package h0730;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 用户调度问题
 * @date 2024/7/30 9:12
 */
public class UserSchedulingProblem {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //用户个数
        int[][] arr = new int[n][3];
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < 3; j++) {
                arr[i][j] = sc.nextInt();
            }
        }
        //第一次选出最小的那个
        int minIndex = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < arr[0].length; i++) {
            if (arr[0][i] < min) {
                min = arr[0][i];
                minIndex = i;
            }
        }
        int sum=arr[0][minIndex];
        for (int i = 1; i < arr.length; i++) {
            int minSource = Integer.MAX_VALUE;
            int temp = -1;
            for (int j = 0; j < arr[i].length; j++) {
                if (j == minIndex) continue;
                if (arr[i][j] < minSource) {
                    minSource = arr[i][j];
                    temp = j;
                }
            }
            minIndex=temp;
            sum+=arr[i][minIndex];
        }

        System.out.println(sum);
    }
}
